<!--
 * @Author: krsea 965837746@qq.com
 * @Date: 2025-03-04 09:54:43
 * @LastEditors: krsea 965837746@qq.com
 * @LastEditTime: 2025-03-04 11:03:35
 * @FilePath: \vue3-code\2306\week3\3.props的值是对象.html
 * @Description: 
 * 
 * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved. 
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>props的值是对象</title>
    <!-- 引入vue.js -->
    <script src="../js/vue.js"></script>
</head>

<body>
    <!-- 挂载点 -->
    <div id="app">
        <p>姓名: {{name}} 年龄：{{age}}</p>
        <my-component-name :name="name" :age="age"></my-component-name>
    </div>

    <!-- // 定义组件模板 -->
    <template id="temp">
        <div>
           <h3>传到子组件修改后的数据</h3>
            子组件姓名:{{myname}}<br>
            子组件年龄:{{myage}}<br>
            子组件爱好:{{love}}<br>
        </div>
    </template>

    <!-- 使用javascript 脚本 -->
    <script type="text/javascript">
        Vue.component('my-component-name', {
            // ... options ...
            props: {
              age:Number,
              name:String,
              love:{
                type:String,
                default:'打球'
              }
            },
            template: '#temp',
            data(){
                return{
                    myage:this.age - 10,
                    myname:'小'+this.name,
                }
            },  
        })
        // 创建app vue实例
        var app = new Vue({
            el: '#app',
            data: {
                msg:'小伙子，你太棒了！',
                name:'萧十一郎',
                age:20,
            }
        })
    </script>
</body>

</html>